package cn.edu.scau.cmi.liuxintong.Singleton;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

public class Marshal {
	  private String name;
	  private static Set<Marshal> marshalSet = new HashSet<Marshal>();
	  private  Marshal(String name) {
		  this.name = name;
	  }
	  public  static int addMarshal(String name){
		 int flag=-1;
		  if(marshalSet.size()<10) {
			  Marshal marshal = new Marshal(name);
			if( ! marshalSet.add(marshal))
				flag=0;
		  }
		  return  flag;
	  }
	  public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((name == null) ? 0 : name.hashCode());
			return result;
		}

	  public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			 Marshal other = ( Marshal) obj;
			if (name == null) {
				if (other.name != null)
					return false;
			} else if (!name.equals(other.name))
				return false;
			return true;
		}

	
}
